﻿using UnityEngine;
using System.Collections;

public class CameraScript : MonoBehaviour {
	public Vector3 targetPosition;
	float smoothFactor = 4;
	public bool bMoving;

	public void Start()
	{
		targetPosition = new Vector3(0,0,0);
		bMoving = false;
	}

	public void MoveUP()
	{
//		Vector3 vec = new Vector3(0,2.84f,0);
		if(!bMoving)
		{
			targetPosition = transform.position;
			targetPosition.y += 2.84f;
			bMoving = true;
		}
//		transform.Translate(vec);
	}

	public void MoveDown()
	{
//		Vector3 vec = new Vector3(0,-2.84f,0);
		if(!bMoving)
		{
			targetPosition = transform.position;
			targetPosition.y -= 2.84f;
			bMoving = true;
		}
//		transform.Translate(vec);
	}

	void Update()
	{
		if(bMoving){
			transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smoothFactor);
		}
		if(bMoving && Mathf.Abs(transform.position.y-targetPosition.y) < 0.002f) {
			bMoving = false;
			MoveToCenterRoom();
		}
	}

	void MoveToCenterRoom()
	{
		Debug.Log("MOVE TO BASE");
		transform.Translate(-transform.position.x, -transform.position.y, -10);
	}
}
